package com.kitty.game.fight.bean;

import com.kitty.game.config.PetSet;
import com.kitty.game.enter.FiedValue;
import com.kitty.game.fight.message.vo.FightMember;
import com.kitty.game.fight.bean.FightObject;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class MonsterFightObject extends FightObject {

    public MonsterFightObject(PetSet petSet, Short pos, int monsterId) {
        double randomLife = 1 + (new Random().nextInt(30) + 10) / 100.00;
        setName(petSet.getName());
        setLevel(petSet.getLevel());
        setDefense(petSet.getDef());
        setSpeed((short) petSet.getSpeed());
        setMagPower(petSet.getPower());
        setPhyPower(petSet.getPower());
        setMaxLife((int) (petSet.getLife() * randomLife));
        setMaxMana(petSet.getMana());
        setCurrMana(petSet.getMana());
        setCurrLife((int) (petSet.getLife() * randomLife));
        setPolar(petSet.getPolar());
        setSkillIds(petSet.getSkillIds());
        setIcon(petSet.getIcon());
        setPos(pos);
        setId(monsterId);
    }

    @Override
    public FightMember asFightMember() {
        FightMember fightMember = new FightMember();
        fightMember.setId(getId());
        fightMember.setPosition((short) getPos());
        fightMember.setIcon((short) getIcon());
        fightMember.setList(asFieldValues());
        fightMember.setId(getId());
        return fightMember;
    }

    @Override
    public List<FiedValue> asFieldValues() {
        ArrayList<FiedValue> fiedValues = new ArrayList<>();
        fiedValues.add(new FiedValue(1, 4, getName()));
        fiedValues.add(new FiedValue(40, 7, getIcon()));
        fiedValues.add(new FiedValue(41, 7, (short) 2));
        fiedValues.add(new FiedValue(204, 3, 0));
        fiedValues.add(new FiedValue(341, 1, (byte) 0));
        fiedValues.add(new FiedValue(340, 1, (byte) 0));
        return fiedValues;
    }

    @Override
    public int getMagHurt(FightObject target, boolean isPenetrate) {
        return super.getMagHurt(target, isPenetrate);
    }

    @Override
    public int getPhyHurt(FightObject target, boolean isPenetrate) {
        return super.getPhyHurt(target, isPenetrate);
    }

    @Override
    public String toString() {
        return "MonsterFightObject{" +
                "id=" + id +
                ", name='" + name + '\'' +
                '}';
    }
}
